Public Class MerchantFeedback
    Inherits System.Web.UI.Page
    Public nStart As Integer
    Public nInterval As Integer
    Public nFirstRec As Integer
    Public nLastRec As Integer
#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not IsPostBack Then
            InitialControlVar()
        End If
    End Sub
    Private Sub InitialControlVar()
        '-----	initializing control variables
        nStart = 1
        nInterval = 10
        nFirstRec = 1
        nLastRec = 1

        '-----	grabbing passed-in vars
        If Not IsNothing(Request.QueryString("nStart")) Then
            nStart = CInt(Request.QueryString("nStart"))
        ElseIf Not IsNothing(Request.Form("nStart")) Then
            nStart = CInt(Request.Form("nStart"))
        End If
        If Not IsNothing(Request.QueryString("nInterval ")) Then
            nInterval = CInt(Request.QueryString("nInterval "))
        ElseIf Not IsNothing(Request.Form("nInterval ")) Then
            nInterval = CInt(Request.Form("nInterval "))
        End If

    End Sub
    Public Sub Display_merchFedbk()
        ''initializing record cursor
        Dim nCursor As Integer
        Dim odetail As gaFeedBack.FeedBackAdmin
        Dim rst As DataSet
        Dim strHml As String
        Dim i As Integer
        Dim GAPORTALID As String
        Dim CompanyID As String
        Dim EntryDate As Date
        Dim DescriptionText, MessageText As String
        Dim URL As String

        '-----	initializing record cursor
        nCursor = 1
        '-----	getting feedback records from the database
        odetail = New gaFeedBack.FeedBackAdmin
        odetail.DBConnectstring = Application("DSN")
        rst = New DataSet
        rst = odetail.GetDetailConts()
        strHml = ""
        If rst.Tables(0).Rows.Count > 0 Then
            '-----	check to see if we are not on the first page
            If nStart > 1 Then
                '-----	progressing recordset to the correct record
                If nCursor < nStart Then
                    'Do While Not rst.eof And nCursor < nStart
                    nCursor = nCursor + rst.Tables(0).Rows.Count
                    'rst.'movenext()
                    'Loop
                End If
            End If
            nFirstRec = nCursor
            '-----	displaying the feedback records
            'Do While Not rst.eof And 
            For i = 0 To rst.Tables(0).Rows.Count - 1
                If nCursor < nStart + nInterval Then
                    GAPORTALID = rst.Tables(0).Rows(i).Item("GAPORTAL_ID")
                    CompanyID = rst.Tables(0).Rows(i).Item("Company_id")
                    EntryDate = rst.Tables(0).Rows(i).Item("EntryDate")
                    If rst.Tables(0).Rows(i).Item("URL") <> "" Then
                        URL = rst.Tables(0).Rows(i).Item("URL")
                    Else
                        URL = "&nbsp;"
                    End If
                    'If Len(URL) > 35 Then
                    '    URL = WrapURL(URL, 35)
                    'End If
                    DescriptionText = rst.Tables(0).Rows(i).Item("DescriptionText")
                    MessageText = rst.Tables(0).Rows(i).Item("MessageText")
                    If Len(MessageText) > 20 Then
                        MessageText = Left(MessageText, 20) & "..."
                    End If

                    strHml += "<tr>"
                    strHml += "<td valign='top'><a href='FeedbackDetails.asp?loc=" & nCursor & ">&amp;nStart=" & nStart & ">&amp; nInterval=" & nInterval & "'>" & FormatDateTime(EntryDate, vbShortDate) & "</a></td>"
                    strHml += "<td valign='top'>" & DescriptionText & "</td>"
                    strHml += "<td valign='top'>" & GAPORTALID & " " & CompanyID & " </td>"
                    strHml += "<td valign='top'>" & URL & "</td>"
                    strHml += "<td valign='top'>" & MessageText & "</td></tr>"
                    nCursor = nCursor + 1
                    'rst.movenext()
                End If
            Next
            nLastRec = nCursor - 1
            'If Not rst.eof Then
            '-----	getting total number of feedback submissions
            'Do While Not rst.eof
            nCursor = nCursor + rst.Tables(0).Rows.Count
            'rst.movenext()
            'Loop

            'End If
            nCursor = nCursor - 1
            '-----	drawing next, previous buttons %>
            strHml += "<tr><td colspan='5' align='center'>"

            strHml += "<table border='0' cellpadding='1' cellspacing='1'><tr><td nowrap>" & nCursor & " "

            strHml += "total records. Displaying" & nFirstRec & " to " & nLastRec & ".</td></tr>"

            strHml += "	<tr><td align='center' nowrap><table border='0' cellpadding='1' cellspacing='1'><tr>"

            If nStart > 1 Then
                strHml += "<td><a href='MerchantFeedback.asp?nStart=" & nStart & " - " & nInterval & "&amp;nInterval=" & nInterval & " >'>Previous"
                strHml += "<%=nInterval%></a></td>"

            End If
            If nStart + nInterval <= nCursor Then
                strHml += "<td><a href='MerchantFeedback.aspx?nStart=" & nStart & " + " & nInterval & " &amp;nInterval=" & nInterval & "'>Next"
                strHml += "<%=nInterval%></a></td>"
            End If
            strHml += "</tr></table></td></tr></table></td></tr>"

        Else
            strHml += "<tr><td colspan='5'>No merchant feedback found.</td></tr>"

        End If
        Response.Write(strHml)
    End Sub
    'Public Function WrapURL(ByVal url, ByVal length) As String
    '    Dim newURL As String
    '    newURL = ""
    '    Buffer = url
    '    'Response.Write "this is the original url = " & url & "<br><br>"
    '    While Buffer.ByteLength > length
    '        slashpos = InStrRev(Left(Buffer, length), "/")
    '        If slashpos = 0 Then
    '            slashpos = length
    '        End If
    '        newURL = newURL & Left(Buffer, slashpos) & "<br>"
    '        Buffer = Right(Buffer, Len(Buffer) - slashpos)
    '        'Response.Write "buffer = " & buffer & "<br>"
    '        'Response.Write "newurl = " & newurl & "<br>"
    '    End While
    '    newURL = newURL & Buffer

    '    WrapURL = newURL
    'End Function
End Class
